<?php
class Apply1Controller extends EController
{
    public $layout = 'main';
    //过滤器
    public function filters()
    {
        return array(
            array(
                'application.filters.BackEndAuthRequestFilter',
            )
        );
    }

    public function actionlist()
    {

        $cookie = new CHttpCookie('ApplyController', str_replace(Yii::app()->request->baseUrl."/","",$_SERVER["REQUEST_URI"]));
        $cookie->expire = time()+60*60*24*30;
        Yii::app()->request->cookies['aiuserhttpbor']=$cookie;
        $this->layout='list';
        $this->son_menu=0;
        $act_list=ActionMenuHelper::getHiddenMenu();
        $model=new ActApply('search');
        if(isset($_GET['ActApply'])){
            $model->attributes=$_GET['ActApply'];
        }
        $this->render('list',array(
                'dataProvider'=>$model->search(),
                'act_list'=>$act_list,
                'model'=>$model)
        );
    }

    //获取id
    private function _getId(){
        if(!isset($_GET['id']) || !is_numeric($_GET['id'])){
            throw new CHttpException(400,'Invalid request. id is required!');
        }
        return $_GET['id'];
    }

    public function actionInfo() {
        $id = $this->_getId();
        $order = ActApply::model()->findByPk($id);
        if ($order->act->real_material) {
            $goodsInfo = json_decode($order->act->real_material, true);
        } else {
            $goodsInfo=[];
        }

        $address =  $order->user->shop->province.$order->user->shop->city.$order->user->shop->district.$order->user->shop->connect_address;

        $this->render('info',array("count"=>$order->act_num,'goodsInfo'=>$goodsInfo,'name'=>$order->user->connect_name,"phone"=>$order->user->connect_phone,"addr" =>$address,"order"=>$order));
    }


}